/*
Audica Uploader - application for convenient uploading to various file hostings
Copyright (C) 2011-2012 Makarov Andrey (Winand)

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

#include "global.h"
#include <QDir>
#include <QApplication>
#include <QVariant>
#include "dbgform.h"

/*
Returns application main path. Under debug mode it
returns current path, otherwise returns executable path
*/
QString appPath() {
#ifdef QT_DEBUG
    return QDir::currentPath();
#else
    return qApp->applicationDirPath();
#endif
}

void customDbgHandler(QtMsgType type, const char *msg) {
    static DbgForm wnd;
    static bool verbose = qApp->property("g_verbose").toBool();
    wnd.addMessage(msg);
    switch (type) {
    case QtDebugMsg:
        if(verbose) wnd.show();
        break;
    case QtWarningMsg:
        wnd.show();
        break;
    case QtCriticalMsg:
        wnd.show();
        break;
    case QtFatalMsg:
        wnd.show();
        /*fprintf(stderr, "Fatal: %s\n", msg);
        abort();*/
    }
}
